﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TwilioSharp.Code.Twilio;

namespace TwilioSharp.Controllers
{
    public class OutgoingController : Controller
    {
        //
        // GET: /Outgoing/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult PlaceCall()
        {
            var twilioApi = new TwilioApi();
            twilioApi.PlaceCall(
                Request.Form["PhoneNumber"], 
                new Uri(String.Format("{0}://{1}/{2}", Request.Url.Scheme,Request.Url.Authority,"/TwilioListener/Voice/OutBoundCallInstructions")));
            return RedirectToAction("Index");
        }

    }
}
